{include file="./header" title="$list.name" /}
<div class="container-fluid">
<form class="form-horizontal card card-block" action="" method="post" enctype="multipart/form-data">
  
  <p class="card-title">{:lang('模型字段')}</p>
  <div class="card-text">
  {foreach name='list.data' item='val'}
  
  <fieldset class="form-group row">
  
  	<div class="col-sm-3">
    	<label for="name[]" class="sr-only">栏目名</label>
		<input name="name[]" type="text" class="form-control" id="name" placeholder="{:lang('名称')}" value="{$val.0}">
    </div>
    <div class="col-sm-3">
		<label for="field[]" class="sr-only">字段名</label>
		<input name="field[]" type="text" class="form-control" id="name" placeholder="{:lang('字段')}" value="{$key}">
    </div>
    
    <div class="col-sm-4">
		<label for="type[]" class="sr-only">{:lang('类型')}</label>
        <select name="type[]" class="form-control" id="type[]">
          <option value="text" {$val['1']=='text'?'selected ':''}>{:lang('文本')}</option>
          <option value="textarea" {$val['1']=='textarea'?'selected ':''}>{:lang('多行文本')}</option>
          <option value="select" {$val['1']=='select'?'selected ':''}>{:lang('选项')}</option>
          <option value="checkbox" {$val['1']=='checkbox'?'selected ':''}>{:lang('多选')}</option>
          <option value="radio" {$val['1']=='radio'?'selected ':''}>{:lang('单选')}</option>
        </select>
  	</div>
    <div class="col-sm-2">
           	  <a class="btn btn-primary" href="{:url('mod_del?',['id'=>input('id'),'field'=>$key])}" role="button">{:lang('删除字段')}</a>
	</div>
    <div class="col-sm-12" style="margin-top:10px;">
    <label for="value[]" class="sr-only">数据</label>
    <textarea name="value[]" rows="3" class="form-control">{$val.2}</textarea>
    </div>
   
  </fieldset>
  {/foreach}
  
  <div class="" role="group" aria-label="...">
    <input type="submit" class="btn btn-primary" value="{:lang('提交')}" />
    <notempty name="list.table">
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ziduanadd">{:lang('添加字段')}</button>
    </notempty>
  </div>
  
  </div>

</form>
</div>

<!-- Modal -->
<div class="modal fade" id="ziduanadd">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      
      <div class="modal-header">
        <h4 class="modal-title">{:lang('添加字段')}</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
          <span class="sr-only">Close</span>
        </button>
      </div>
      
      
      <div class="modal-body">
		<form action="{:url('?action=add&id='.input('id'))}" class="" method="post" enctype="application/x-www-form-urlencoded" id="ziduan">
            <div class="row">
			<fieldset class="form-group col-sm-4">
    			<label for="name" class="sr-only">{:lang('名称')}</label>
				<input name="name" type="text" class="form-control" id="name" placeholder="{:lang('名称')}">
    		</fieldset>
            
    		<fieldset class="form-group col-sm-4">
				<label for="field" class="sr-only">{:lang('字段')}</label>
				<input name="field" type="text" class="form-control" id="field" placeholder="{:lang('字段')}">
    		</fieldset>
    		
    		<fieldset class="form-group col-sm-4">
				<label for="type" class="sr-only">{:lang('类型')}</label>
				<select name="type" class="form-control" id="type">
				<option value="text">{:lang('文本')}</option>
				<option value="textarea">{:lang('多行文本')}</option>
				<option value="select">{:lang('选项')}</option>
				<option value="checkbox">{:lang('多选')}</option>
                <option value="radio">{:lang('单选')}</option>
				</select>
			</fieldset>
            </div>
            <div class="row">
			<fieldset class="form-group col-sm-12">
				<label for="value" class="sr-only">数据</label>
				<textarea name="value" rows="3" class="form-control" placeholder="{:lang('输入数据，如：汽车,火车,飞机')}" id="value"></textarea>
			</fieldset>
            </div>
		</form>
      </div>
      
      <div class="modal-footer">
        <button type="button" onclick="post('#ziduan')" class="btn btn-primary">{:lang("提交")}</button>
      </div>
      
    </div>
  </div>
</div>




<script>
$(document).ready(function(e) {
	//获取拼音字段
	$("#ziduanadd #name").change(function(e) {
        value = $("#ziduanadd #name").val();
		$.post("{:url('pinyin')}",{
			str:value,	
		},function(data,status){
			if($("#ziduanadd #field").val() == ''){
				$("#ziduanadd #field").val(data);
			}

  		});
    });
	
	
});

function post(id){
		//$("+id+").submit();
		$("#ziduan").submit();
	}
	
	function aa(){
		alert("12123");	
	}
</script>
{include file="./footer" /}
